package exemplointerface;

import java.util.ArrayList;
import java.util.List;
import javax.swing.JOptionPane;

public class NovelaTela extends javax.swing.JFrame {
List <Novela> lista;
Integer posicao;

    public NovelaTela() {
        initComponents();
        lista = new ArrayList <Novela>();
        posicao = 0;
    }

    /**
     * This method is called from within the constructor to initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is always
     * regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        jColorChooser1 = new javax.swing.JColorChooser();
        jLabel1 = new javax.swing.JLabel();
        jLabel2 = new javax.swing.JLabel();
        jLabel3 = new javax.swing.JLabel();
        jLabel4 = new javax.swing.JLabel();
        jLabel5 = new javax.swing.JLabel();
        jLabel6 = new javax.swing.JLabel();
        jLabel7 = new javax.swing.JLabel();
        jLabel8 = new javax.swing.JLabel();
        jLabel9 = new javax.swing.JLabel();
        jLabel10 = new javax.swing.JLabel();
        jLabel11 = new javax.swing.JLabel();
        txtTitulo = new javax.swing.JTextField();
        txtPrimCap = new javax.swing.JTextField();
        txtUltCap = new javax.swing.JTextField();
        txtAutor = new javax.swing.JTextField();
        txtHorario = new javax.swing.JTextField();
        txtEmisora = new javax.swing.JTextField();
        txtIbope = new javax.swing.JTextField();
        selecviolencia = new javax.swing.JComboBox();
        selecsexo = new javax.swing.JComboBox();
        selecdrogas = new javax.swing.JComboBox();
        botaolimpar = new javax.swing.JButton();
        jPanel1 = new javax.swing.JPanel();
        botaoprimeiro = new javax.swing.JButton();
        botaoanterior = new javax.swing.JButton();
        botaoproximo = new javax.swing.JButton();
        botaoultimo = new javax.swing.JButton();
        botaoinserir = new javax.swing.JButton();
        botaoexcluir = new javax.swing.JButton();
        botaoconsultar = new javax.swing.JButton();
        botaoclassific = new javax.swing.JButton();

        setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);

        jLabel1.setFont(new java.awt.Font("Gabriola", 1, 24)); // NOI18N
        jLabel1.setForeground(new java.awt.Color(0, 153, 255));
        jLabel1.setText("NOVELA");

        jLabel2.setFont(new java.awt.Font("Tahoma", 1, 11)); // NOI18N
        jLabel2.setText("Título: ");

        jLabel3.setFont(new java.awt.Font("Tahoma", 1, 11)); // NOI18N
        jLabel3.setText("Data/Primeiro Capítulo:");

        jLabel4.setFont(new java.awt.Font("Tahoma", 1, 11)); // NOI18N
        jLabel4.setText("Data/Último Capítulo:");

        jLabel5.setFont(new java.awt.Font("Tahoma", 1, 11)); // NOI18N
        jLabel5.setText("Autor:");

        jLabel6.setFont(new java.awt.Font("Tahoma", 1, 11)); // NOI18N
        jLabel6.setText("Horário de Exibição:");

        jLabel7.setFont(new java.awt.Font("Tahoma", 1, 11)); // NOI18N
        jLabel7.setText("Emissora:");

        jLabel8.setFont(new java.awt.Font("Tahoma", 1, 11)); // NOI18N
        jLabel8.setText("Pontuação/IBOPE:");

        jLabel9.setFont(new java.awt.Font("Tahoma", 1, 11)); // NOI18N
        jLabel9.setText("Cenas de Violência:");

        jLabel10.setFont(new java.awt.Font("Tahoma", 1, 11)); // NOI18N
        jLabel10.setText("Cenas de Sexo:");

        jLabel11.setFont(new java.awt.Font("Tahoma", 1, 11)); // NOI18N
        jLabel11.setText("Cenas com Drogas:");

        txtPrimCap.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                txtPrimCapActionPerformed(evt);
            }
        });

        selecviolencia.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "Selecione", "Sim", "Não" }));

        selecsexo.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "Selecione", "Sim", "Não" }));

        selecdrogas.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "Selecione", "Sim", "Não" }));

        botaolimpar.setText("Limpar");
        botaolimpar.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                botaolimparActionPerformed(evt);
            }
        });

        jPanel1.setBorder(javax.swing.BorderFactory.createTitledBorder("Navegação"));

        botaoprimeiro.setText("Primeiro");
        botaoprimeiro.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                botaoprimeiroActionPerformed(evt);
            }
        });

        botaoanterior.setText("Anterior");
        botaoanterior.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                botaoanteriorActionPerformed(evt);
            }
        });

        botaoproximo.setText("Próximo");
        botaoproximo.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                botaoproximoActionPerformed(evt);
            }
        });

        botaoultimo.setText("Último");
        botaoultimo.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                botaoultimoActionPerformed(evt);
            }
        });

        javax.swing.GroupLayout jPanel1Layout = new javax.swing.GroupLayout(jPanel1);
        jPanel1.setLayout(jPanel1Layout);
        jPanel1Layout.setHorizontalGroup(
            jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel1Layout.createSequentialGroup()
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                .addComponent(botaoprimeiro)
                .addGap(18, 18, 18)
                .addComponent(botaoanterior)
                .addGap(18, 18, 18)
                .addComponent(botaoproximo)
                .addGap(18, 18, 18)
                .addComponent(botaoultimo)
                .addContainerGap())
        );
        jPanel1Layout.setVerticalGroup(
            jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel1Layout.createSequentialGroup()
                .addGap(31, 31, 31)
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(botaoprimeiro)
                    .addComponent(botaoanterior)
                    .addComponent(botaoproximo)
                    .addComponent(botaoultimo))
                .addContainerGap(46, Short.MAX_VALUE))
        );

        botaoinserir.setText("Inserir");
        botaoinserir.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                botaoinserirActionPerformed(evt);
            }
        });

        botaoexcluir.setText("Excluir");
        botaoexcluir.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                botaoexcluirActionPerformed(evt);
            }
        });

        botaoconsultar.setText("Consultar");
        botaoconsultar.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                botaoconsultarActionPerformed(evt);
            }
        });

        botaoclassific.setText("Classificação");
        botaoclassific.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                botaoclassificActionPerformed(evt);
            }
        });

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
        getContentPane().setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(layout.createSequentialGroup()
                        .addGap(25, 25, 25)
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addGroup(layout.createSequentialGroup()
                                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                    .addComponent(jLabel2)
                                    .addComponent(jLabel3)
                                    .addComponent(jLabel4)
                                    .addComponent(jLabel5)
                                    .addComponent(jLabel6)
                                    .addComponent(jLabel7)
                                    .addComponent(jLabel8)
                                    .addComponent(jLabel9)
                                    .addComponent(jLabel10)
                                    .addComponent(jLabel11))
                                .addGap(36, 36, 36)
                                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                                    .addComponent(txtTitulo)
                                    .addComponent(txtPrimCap)
                                    .addComponent(txtUltCap)
                                    .addComponent(txtAutor)
                                    .addComponent(txtHorario)
                                    .addComponent(txtEmisora)
                                    .addComponent(txtIbope)
                                    .addComponent(selecviolencia, 0, 187, Short.MAX_VALUE)
                                    .addComponent(selecsexo, 0, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                                    .addComponent(selecdrogas, 0, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)))
                            .addComponent(jPanel1, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)))
                    .addGroup(layout.createSequentialGroup()
                        .addGap(159, 159, 159)
                        .addComponent(jLabel1))
                    .addGroup(layout.createSequentialGroup()
                        .addGap(50, 50, 50)
                        .addComponent(botaoinserir)
                        .addGap(10, 10, 10)
                        .addComponent(botaolimpar)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                        .addComponent(botaoexcluir)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                        .addComponent(botaoconsultar))
                    .addGroup(layout.createSequentialGroup()
                        .addGap(142, 142, 142)
                        .addComponent(botaoclassific)))
                .addContainerGap(18, Short.MAX_VALUE))
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(jLabel1)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jPanel1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addGap(18, 18, 18)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel2)
                    .addComponent(txtTitulo, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addGap(18, 18, 18)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel3)
                    .addComponent(txtPrimCap, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addGap(18, 18, 18)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel4)
                    .addComponent(txtUltCap, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addGap(18, 18, 18)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel5)
                    .addComponent(txtAutor, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addGap(18, 18, 18)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel6)
                    .addComponent(txtHorario, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addGap(18, 18, 18)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel7)
                    .addComponent(txtEmisora, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addGap(18, 18, 18)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel8)
                    .addComponent(txtIbope, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addGap(18, 18, 18)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel9)
                    .addComponent(selecviolencia, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addGap(18, 18, 18)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel10)
                    .addComponent(selecsexo, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addGap(18, 18, 18)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel11)
                    .addComponent(selecdrogas, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addGap(18, 18, 18)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(botaolimpar)
                    .addComponent(botaoinserir)
                    .addComponent(botaoexcluir)
                    .addComponent(botaoconsultar))
                .addGap(18, 18, 18)
                .addComponent(botaoclassific, javax.swing.GroupLayout.PREFERRED_SIZE, 22, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addContainerGap(24, Short.MAX_VALUE))
        );

        pack();
    }// </editor-fold>//GEN-END:initComponents
     
    private void Limpar()
    {
        txtTitulo.setText("");
        txtPrimCap.setText("");
        txtUltCap.setText("");
        txtAutor.setText("");
        txtHorario.setText("");
        txtEmisora.setText("");
        txtIbope.setText("");
        selecviolencia.setSelectedIndex(0);
        selecsexo.setSelectedIndex(0);
        selecdrogas.setSelectedIndex(0);
    }
    private void txtPrimCapActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_txtPrimCapActionPerformed
        // TODO add your handling code here:
    }//GEN-LAST:event_txtPrimCapActionPerformed

    private void botaolimparActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_botaolimparActionPerformed
        Limpar();
    }//GEN-LAST:event_botaolimparActionPerformed

    private void botaoanteriorActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_botaoanteriorActionPerformed
        botaoprimeiro.setEnabled(true);
        botaoanterior.setEnabled(true);
        botaoproximo.setEnabled(true);
        botaoultimo.setEnabled(true);
        
        
        
        if (posicao > 0)
        {
            posicao = posicao - 1;
        
            Novela elemento = lista.get(posicao);
            
            txtTitulo.setText(elemento.getTitulo());
            txtPrimCap.setText(elemento.getDatapcap());
            txtUltCap.setText(elemento.getDataucap());
            txtAutor.setText(elemento.getAutor());
            txtHorario.setText(elemento.getHoraexib());
            txtEmisora.setText(elemento.getEmisora());
            txtIbope.setText(elemento.getIbop().toString());
            
            if (elemento.isViolencia() == true)
            {
                selecviolencia.setSelectedIndex(1);
            }
            else
            {
                selecviolencia.setSelectedIndex(2);
            }
            
            if (elemento.isSexo() == true)
            {
                selecsexo.setSelectedIndex(1);
            }
            else
            {
                selecsexo.setSelectedIndex(2);
            }
            
            if (elemento.isDrogas() == true)
            {
                selecdrogas.setSelectedIndex(1);
            }
            else
            {
                selecdrogas.setSelectedIndex(2);
            }
            
            if (lista.size() == 1)
            {
                botaoproximo.setEnabled(false);
            }
        }
    }//GEN-LAST:event_botaoanteriorActionPerformed

    private void botaoprimeiroActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_botaoprimeiroActionPerformed
        botaoprimeiro.setEnabled(true);
        botaoanterior.setEnabled(false);
        botaoproximo.setEnabled(true);
        botaoultimo.setEnabled(true); 
        
        if (lista.size() > 0)
        {
            posicao = 0;
            
            Novela elemento = lista.get(0);
            
            txtTitulo.setText(elemento.getTitulo());
            txtPrimCap.setText(elemento.getDatapcap());
            txtUltCap.setText(elemento.getDataucap());
            txtAutor.setText(elemento.getAutor());
            txtHorario.setText(elemento.getHoraexib());
            txtEmisora.setText(elemento.getEmisora());
            txtIbope.setText(elemento.getIbop().toString());
            
            if (elemento.isViolencia() == true)
            {
                selecviolencia.setSelectedIndex(1);
            }
            else
            {
                selecviolencia.setSelectedIndex(2);
            }
            
            if (elemento.isSexo() == true)
            {
                selecsexo.setSelectedIndex(1);
            }
            else
            {
                selecsexo.setSelectedIndex(2);
            }
            
            if (elemento.isDrogas() == true)
            {
                selecdrogas.setSelectedIndex(1);
            }
            else
            {
                selecdrogas.setSelectedIndex(2);
            }
            
            if (lista.size() == 1)
            {
                botaoproximo.setEnabled(false);
            }
        }
    }//GEN-LAST:event_botaoprimeiroActionPerformed

    private void botaoproximoActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_botaoproximoActionPerformed
        botaoprimeiro.setEnabled(true);
        botaoanterior.setEnabled(true);
        botaoproximo.setEnabled(true);
        botaoultimo.setEnabled(true);    
        
        posicao = posicao + 1;
        
            Novela elemento = lista.get(posicao);
        
            txtTitulo.setText(elemento.getTitulo());
            txtPrimCap.setText(elemento.getDatapcap());
            txtUltCap.setText(elemento.getDataucap());
            txtAutor.setText(elemento.getAutor());
            txtHorario.setText(elemento.getHoraexib());
            txtEmisora.setText(elemento.getEmisora());
            txtIbope.setText(elemento.getIbop().toString());
            
            if (elemento.isViolencia() == true)
            {
                selecviolencia.setSelectedIndex(1);
            }
            else
            {
                selecviolencia.setSelectedIndex(2);
            }
            
            if (elemento.isSexo() == true)
            {
                selecsexo.setSelectedIndex(1);
            }
            else
            {
                selecsexo.setSelectedIndex(2);
            }
            
            if (elemento.isDrogas() == true)
            {
                selecdrogas.setSelectedIndex(1);
            }
            else
            {
                selecdrogas.setSelectedIndex(2);
            }
            
            if (lista.size() == 1)
            {
                botaoproximo.setEnabled(false);
            }
            
            if (posicao == lista.size() - 1)
            {
                botaoproximo.setEnabled(false);
                botaoultimo.setEnabled(false);
            }
    }//GEN-LAST:event_botaoproximoActionPerformed

    private void botaoultimoActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_botaoultimoActionPerformed
        botaoprimeiro.setEnabled(true);
        botaoanterior.setEnabled(true);
        botaoproximo.setEnabled(false);
        botaoultimo.setEnabled(false);
        
        posicao = (lista.size() - 1);
        
        Novela elemento = lista.get(posicao);
        
            txtTitulo.setText(elemento.getTitulo());
            txtPrimCap.setText(elemento.getDatapcap());
            txtUltCap.setText(elemento.getDataucap());
            txtAutor.setText(elemento.getAutor());
            txtHorario.setText(elemento.getHoraexib());
            txtEmisora.setText(elemento.getEmisora());
            txtIbope.setText(elemento.getIbop().toString());
            
            if (elemento.isViolencia() == true)
            {
                selecviolencia.setSelectedIndex(1);
            }
            else
            {
                selecviolencia.setSelectedIndex(2);
            }
            
            if (elemento.isSexo() == true)
            {
                selecsexo.setSelectedIndex(1);
            }
            else
            {
                selecsexo.setSelectedIndex(2);
            }
            
            if (elemento.isDrogas() == true)
            {
                selecdrogas.setSelectedIndex(1);
            }
            else
            {
                selecdrogas.setSelectedIndex(2);
            }
            
            if (lista.size() == 1)
            {
                botaoproximo.setEnabled(false);
            }
    }//GEN-LAST:event_botaoultimoActionPerformed

    private void botaoinserirActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_botaoinserirActionPerformed
        Novela nov = new Novela();
        
        nov.setTitulo(txtTitulo.getText());
        nov.setDatapcap(txtPrimCap.getText());
        nov.setDataucap(txtUltCap.getText());
        nov.setAutor(txtAutor.getText());
        nov.setHoraexib(txtHorario.getText());
        nov.setEmisora(txtEmisora.getText());
        nov.setIbop(Integer.parseInt(txtIbope.getText()));
        
        if (selecviolencia.getSelectedItem().toString().equals("Sim") == true)
        {
            nov.setViolencia(true);
        }
        else
        {
            nov.setViolencia(false);
        }
        
        if(selecsexo.getSelectedItem().toString().equals("Sim") == true)
        {
            nov.setSexo(true);
        }
        else
        {
            nov.setSexo(false);
        }
        
        if(selecdrogas.getSelectedItem().toString().equals("Sim") == true)
        {
            nov.setDrogas(true);
        }
        else
        {
            nov.setDrogas(false);
        }
        
        lista.add(nov);
        posicao ++;

        Limpar();
    }//GEN-LAST:event_botaoinserirActionPerformed

    private void botaoexcluirActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_botaoexcluirActionPerformed
        lista.remove(lista.get(posicao));
        
        Limpar();
    }//GEN-LAST:event_botaoexcluirActionPerformed

    private void botaoconsultarActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_botaoconsultarActionPerformed
         String pesquisa = JOptionPane.showInputDialog("Digite o título da novela a ser pesquisada: ");
         boolean encontrou = false;
         Integer posicaoachou = 0;
         
         for (Novela novela : lista) 
         {
            if (pesquisa.equals(novela.getTitulo()))
            {
                posicao = posicaoachou;
                encontrou = true;
            
            txtTitulo.setText(novela.getTitulo());
            txtPrimCap.setText(novela.getDatapcap());
            txtUltCap.setText(novela.getDataucap());
            txtAutor.setText(novela.getAutor());
            txtHorario.setText(novela.getHoraexib());
            txtEmisora.setText(novela.getEmisora());
            txtIbope.setText(novela.getIbop().toString());
            
            if (novela.isViolencia() == true)
            {
                selecviolencia.setSelectedIndex(1);
            }
            else
            {
                selecviolencia.setSelectedIndex(2);
            }
            
            if (novela.isSexo() == true)
            {
                selecsexo.setSelectedIndex(1);
            }
            else
            {
                selecsexo.setSelectedIndex(2);
            }
            
            if (novela.isDrogas() == true)
            {
                selecdrogas.setSelectedIndex(1);
            }
            else
            {
                selecdrogas.setSelectedIndex(2);
            }
            
            break;        
            }
            
            posicaoachou++;
            
            if (encontrou == false)
            {
                JOptionPane.showMessageDialog(null, "Novela ainda não cadastrada!");
            }
            
         }
    }//GEN-LAST:event_botaoconsultarActionPerformed

    private void botaoclassificActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_botaoclassificActionPerformed
        Novela nov = new Novela ();
        
        Novela elemento = lista.get(posicao);
        
        JOptionPane.showMessageDialog(null, "Classificação: " + elemento.obterClassificacao());
    }//GEN-LAST:event_botaoclassificActionPerformed

    public static void main(String args[]) {
        /* Set the Nimbus look and feel */
        //<editor-fold defaultstate="collapsed" desc=" Look and feel setting code (optional) ">
        /* If Nimbus (introduced in Java SE 6) is not available, stay with the default look and feel.
         * For details see http://download.oracle.com/javase/tutorial/uiswing/lookandfeel/plaf.html 
         */
        try {
            for (javax.swing.UIManager.LookAndFeelInfo info : javax.swing.UIManager.getInstalledLookAndFeels()) {
                if ("Nimbus".equals(info.getName())) {
                    javax.swing.UIManager.setLookAndFeel(info.getClassName());
                    break;
                }
            }
        } catch (ClassNotFoundException ex) {
            java.util.logging.Logger.getLogger(NovelaTela.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        } catch (InstantiationException ex) {
            java.util.logging.Logger.getLogger(NovelaTela.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        } catch (IllegalAccessException ex) {
            java.util.logging.Logger.getLogger(NovelaTela.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        } catch (javax.swing.UnsupportedLookAndFeelException ex) {
            java.util.logging.Logger.getLogger(NovelaTela.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        }
        //</editor-fold>

        /* Create and display the form */
        java.awt.EventQueue.invokeLater(new Runnable() {
            public void run() {
                new NovelaTela().setVisible(true);
            }
        });
    }

    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JButton botaoanterior;
    private javax.swing.JButton botaoclassific;
    private javax.swing.JButton botaoconsultar;
    private javax.swing.JButton botaoexcluir;
    private javax.swing.JButton botaoinserir;
    private javax.swing.JButton botaolimpar;
    private javax.swing.JButton botaoprimeiro;
    private javax.swing.JButton botaoproximo;
    private javax.swing.JButton botaoultimo;
    private javax.swing.JColorChooser jColorChooser1;
    private javax.swing.JLabel jLabel1;
    private javax.swing.JLabel jLabel10;
    private javax.swing.JLabel jLabel11;
    private javax.swing.JLabel jLabel2;
    private javax.swing.JLabel jLabel3;
    private javax.swing.JLabel jLabel4;
    private javax.swing.JLabel jLabel5;
    private javax.swing.JLabel jLabel6;
    private javax.swing.JLabel jLabel7;
    private javax.swing.JLabel jLabel8;
    private javax.swing.JLabel jLabel9;
    private javax.swing.JPanel jPanel1;
    private javax.swing.JComboBox selecdrogas;
    private javax.swing.JComboBox selecsexo;
    private javax.swing.JComboBox selecviolencia;
    private javax.swing.JTextField txtAutor;
    private javax.swing.JTextField txtEmisora;
    private javax.swing.JTextField txtHorario;
    private javax.swing.JTextField txtIbope;
    private javax.swing.JTextField txtPrimCap;
    private javax.swing.JTextField txtTitulo;
    private javax.swing.JTextField txtUltCap;
    // End of variables declaration//GEN-END:variables
}
